#include "Game.h"


Game::Game()
{
	renderWindow = new sf::RenderWindow(sf::VideoMode(800,800, 32),"Rogue like you");
	tileHandler = new TileHandler();
}

Game::~Game()
{
	//TODO destructor
}

void Game::run()
{
	float scale = 1;
	bool flip = true;
	while(renderWindow->IsOpened())
	{
		sf::Event Event;
		while (renderWindow->GetEvent(Event))
		{
			runEvent(Event);
		}
		loop();
		renderWindow->Clear();
		if(scale < 0.1)
		{
			flip = true;
			scale = 0.1;
		}
		if(scale > 3)
		{
			flip = false;
			scale = 3;
		}
		if(flip)
			scale += (3-scale)*0.002 + 0.0001;
		else
			scale -= scale*0.01;
		for(int x = 0;x < 100;x++)
		{
			for(int y = 0;y < 100;y++)
				tileHandler->draw(x*(100.0f*scale),y*(100.0f*scale),scale,TileHandler::ROCK,renderWindow);
		}

		renderWindow->Display();
	}
}


void Game::loop()
{
	//TODO game logic

}



void Game::runEvent(sf::Event e)
{
	//TODO handle events

}
